//index.js
//获取应用实例
const app = getApp()
const wh = require("../../utils/wh.js");
const WxParse = require('../../wxParse/wxParse.js');
Page({
  data: {
    indicatorDots: true, //轮播圆点
    autoplay: true, //是否自动切换
    interval: 5000, //自动切换时间
    duration: 1000, //滑动动画时长
    indicatorActiveColor: '#ffffff',
    imgUrls: [],
    product_list: {}, // 产品列表
  },
  //事件处理函数
  onLoad: function() {
    this.loop();
    this.carousel();
  },
  loop: function() {
    let that = this,
      postUrl = '/api/madetoorder.loan.Product/product_list';
    wh.Post(postUrl, {}, function(res) {
      WxParse.wxParse('company_desc', 'html', res.company_desc, that);
      WxParse.wxParse('product_desc', 'html', res.product_desc, that);
      that.setData({
        list: res.list
      });
    });
    this.get_setting()
  },
  //获取小程序设置
  get_setting: function () {
    let that = this;
    wh.Post('/api/setting/get', {}, function (res) {
      that.setData({ setting: res });
      // that.audio_setting();//获取成功后返回
    })
  },
  carousel: function() {
    let that = this,
      postUrl = '/api/madetoorder.loan.product/carousel';
    wh.Post(postUrl, {}, function(res) {
      that.setData({
        imgUrls:res
      });
    });
  },
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {
    this.loop();
    wx.stopPullDownRefresh();
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})